[EngSys] Use .ts extensions for samples-dev relative imports - from claude#38824
Open
jeremymeng wants to merge 2 commits into
Open
[EngSys] Use .ts extensions for samples-dev relative imports - from claude#38824jeremymeng wants to merge 2 commits into
jeremymeng wants to merge 2 commits into
Conversation
`dev-tool samples run` now executes samples directly via Node's TypeScript loader, which requires `.ts` extensions for relative imports. Switch all samples-dev sources with relative imports to `.ts` and enable `allowImportingTsExtensions` in the shared samples tsconfig. When publishing samples, the dev-tool now rewrites `.ts` specifiers back to `.js` (and strips `allowImportingTsExtensions` from the generated tsconfig), so published samples continue to compile with `tsc` and run as plain CommonJS JavaScript. Fixes Azure#38822. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Copilot stopped reviewing on behalf of
jeremymeng due to an error
June 4, 2026 19:35
to have `"allowImportingTsExtensions": true`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #38822.
samples-devfrom.jsto.tsso thatdev-tool samples run, which now loads samples directly via Node's TypeScript loader (Node 22.18+), can resolve them.allowImportingTsExtensions: trueto the sharedtsconfig.samples.base.jsonsotsc -p tsconfig.samples.jsoncontinues to acceptsamples-dev/**/*.tssources.dev-tool samples publishso the resultingsamples/tree continues to use.jsspecifiers: relative.tsimports are rewritten to.jsin both the TypeScript output (which is compiled withtscusingnodenextresolution) and the JavaScript (CommonJS) output. The generatedtsconfig.jsonalso stripsallowImportingTsExtensions.ts-importstest fixture undercommon/tools/dev-tool/test/samples/files/that exercises the rewrite for both kinds of published output.Test plan
pnpm testincommon/tools/dev-tool(46 tests pass, including the newts-importsfixture).samples/v1/typescript/src/*.tsandsamples/v1/javascript/*.jsboth reference./utils/*.js.ERR_MODULE_NOT_FOUNDon./utils/helpers.jsno longer reproduces.🤖 Generated with Claude Code